package com.exam.scjp5.objectives.section_3;

import java.io.File;
import java.io.IOException;

public class ExampleFileIO
{
    public static void main(String args[])
    {
        try
        {
            File file1 = new File("test/test1/test2");
            if(file1.exists()== false)
            {
                
                file1.mkdirs();
                //file1.mkdir(); // It will not be working here if you want to create directory tree.
            }
            
            File file2 = new File("parent_test");
            if(file2.exists() == false)
            {
                file2.mkdir();
            }
            
            File file3 = new File("test");
            file3.delete(); // Will not delete bcoz directory is not empty
            File fileSub1 = new File("test/test1/test2"); // Removing sub directories..
            File fileSub2 = new File("test/test1/"); // Removing sub directories..
            fileSub1.delete(); // Removing sub directories..
            fileSub2.delete(); // Removing sub directories..
            file3.delete(); // Try again... 
            
            file2.delete();
            
            File file4 = new File("serializable1.dat");
            System.out.println("Canonical Path : " + file4.getCanonicalPath());
            System.out.println("Absolute Path : " + file4.getAbsolutePath());
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}
